import React from 'react'
import { Navigate } from 'react-router-dom'
import type { RouteObject } from 'react-router-dom'

// 在react中通过懒加载可以防止打包时将所有组件都打包到同一个包中，懒加载就可以很好的解决这个分包处理的工作。
// 在webpack中使用import()函数的导入方式就可以实现

import Create from '../pages/Create'
import SuccessCreate from '../pages/Successcreate'
import CodeList from '../pages/CodeList'
import CodeShare from '../pages/CodeShare'
import ShareCodeByPass from '../pages/ShareCodeByPass'

const routes: RouteObject[] = [
  {
    path: '/',
    element: <Navigate to="/create" replace={true} />
  },
  {
    path: '/create',
    element: <Create />
  },
  {
    path: '/success',
    element: <SuccessCreate />
  },
  {
    path: '/list',
    element: <CodeList />
  },
  {
    path: '/card-shared',
    element: <CodeShare />
  },
  {
    path: '/post/pass',
    element: <ShareCodeByPass />
  }
]

export default routes
